{% load static %}
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>{{title}}</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

     <link rel="stylesheet" href="{% static "layui/css/layui.css"%}"  media="all">

  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
</head>
<body class="baise">





<script src="{% static "layui/layui.js"%}" charset="utf-8"></script>

 <script src="{% static "js/jquery.min.js" %}"></script>

<script>

{% if tishi %}

window.onload=function(){
layer.alert('{{tishi}}', {
  icon: 0,
  skin: 'layer-ext-moon'
    ,time: 2000, //20s后自动关闭
})
}
{% endif %}

{% if jinggao %}

window.onload=function(){
layer.alert('{{jinggao}}', {
  icon: 2,
  skin: 'layer-ext-moon'
    ,time: 2000, //20s后自动关闭

})
}
{% endif %}


{% if yes %}

window.onload=function(){
layer.alert('{{yes}}', {
    icon: 1,
    skin: 'layer-ext-moon' ,
    time: 2000, //20s后自动关闭
})
}
{% endif %}


/*====================django ajax ======*/
jQuery(document).ajaxSend(function(event, xhr, settings) {
    function getCookie(name) {
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
    function sameOrigin(url) {
        // url could be relative or scheme relative or absolute
        var host = document.location.host; // host + port
        var protocol = document.location.protocol;
        var sr_origin = '//' + host;
        var origin = protocol + sr_origin;
        // Allow absolute or scheme relative URLs to same origin
        return (url == origin || url.slice(0, origin.length + 1) == origin + '/') ||
            (url == sr_origin || url.slice(0, sr_origin.length + 1) == sr_origin + '/') ||
            // or any other URL that isn't scheme relative or absolute i.e relative.
            !(/^(\/\/|http:|https:).*/.test(url));
    }
    function safeMethod(method) {
        return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
    }

    if (!safeMethod(settings.type) && sameOrigin(settings.url)) {
        xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
    }
});
/*===============================django ajax end===*/



</script>

  <div class="layui-fluid">
    <div class="layui-card">


            <table class="layui-hide" id="Users" lay-filter="test"></table>

    </div>
  </div>









<div class="layui-row" id="search" style="display:none;">
    <div class="layui-col-md10">

        {% for value in vist %}

                    {% if   "_str" in value.0  %}

             <div class="layui-form layui-from-pane"   style="margin-top:20px" >

                          <div class="demoTable" style="padding: 1px">
                             &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <div class="layui-inline">
                                <input class="layui-input" id="find{{value.0}}" lay-verify="required" autocomplete="off" placeholder="请搜索{{value.1}}">
                            </div>
                            <button class="layui-btn layui-btn-sm layui-btn-radius layui-btn"  id="query{{value.0}}" >搜索{{value.1}}</button>
                        </div>
                      </div>
                    {% elif "_int" in value.0 %}

        <div class="layui-form layui-from-pane"   style="margin-top:20px" >

                          <div class="demoTable" style="padding: 1px">
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <div class="layui-inline">
                                <input class="layui-input" id="find{{value.0}}" lay-verify="required" autocomplete="off" placeholder="请搜索{{value.1}}">
                            </div>
                            <button class="layui-btn layui-btn-sm layui-btn-radius layui-btn"  id="query{{value.0}}" >搜索{{value.1}}</button>
                        </div>
                      </div>


                             {% elif "_time" in value.0 %}

        <div class="layui-form layui-from-pane"   style="margin-top:20px" >

                          <div class="demoTable" style="padding: 1px">
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <div class="layui-inline">
                                <input class="layui-input" id="find{{value.0}}" lay-verify="required" autocomplete="off" placeholder="请搜索{{value.1}}">
                            </div>
                            <button class="layui-btn layui-btn-sm layui-btn-radius layui-btn"  data-type="reload" id="query{{value.0}}" >搜索{{value.1}}</button>
                        </div>
                      </div>


                    {% endif %}





        {% endfor %}


<div class="layui-form layui-from-pane"   style="margin-top:20px" >
<div class="layui-word-aux">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;目前版本，暂不支持多条件联合搜索</div>
     </div>
    </div>
</div>









<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">






        <button class="layui-btn layui-btn-sm layui-btn-warm"lay-event="isAll">刷新页面</button>



    </div>

</script>
<script type="text/html" id="barDemo">
    {% if update %}
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="menu">访问权限</a>

      {% endif %}
{% if update %}
    <a class="layui-btn layui-btn-xs" lay-event="added">增加权限</a>
    {% endif %}
{% if update %}
    <a class="layui-btn   layui-btn-normal layui-btn-xs" lay-event="update">修改权限</a>
    {% endif %}
{% if update %}
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除权限</a>
    {% endif %}
    {% if update %}
    <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="see">开发者权限</a>
    {% endif %}
</script>

<style type="text/css">

    td div.layui-table-cell{height:28px;
        line-height: 28px;
        position: relative;
        text-overflow: ellipsis;
        white-space: nowrap;
        box-sizing: border-box;
        padding: 0px 15px;
        overflow: hidden;
    }
</style>

<script>
    layui.use(['table', 'form', 'layer','upload'], function () {
        var table = layui.table,
            layer = layui.layer,
            upload = layui.upload,
            form = layui.form;
        table.render({
            elem: '#Users'
            ,url:'/{{get_url}}_json/'
            ,type:'post'
             {% if xitong.toolbar_bool %}
                ,toolbar: '#toolbarDemo'
             ,defaultToolbar: ['filter', '{{xitong.exports_str}}', '{{xitong.print_str}}',]
            {% endif %}
            {% if xitong.page_bool %}
            ,page: true
             {% endif %}
            ,skin:'{{xitong.skinline_str}}'

            ,size: '{{xitong.skinsize_str}}'

            ,title: '{{title}}'
            ,cellMinWidth: {{xitong.inwidth_int}} //全局定义常规单元格的最小宽度，
            ,limit:{{xitong.limit_int}}
         ,cols:[[
      {type: 'checkbox', fixed: 'left'}
      ,{field:'{{zd_list.0.0}}', title:'{{zd_list.1.0}}', width:60,  unresize: true, sort: true , align:'center' },
            {% if zd_list.0.1 %}
            {field:'{{zd_list.0.1}}', width:100, title:'{{zd_list.1.1}}', sort: true , align:'center' },
            {% endif %}
            {% if zd_list.0.2 %}
            {field:'{{zd_list.0.2}}', title:'{{zd_list.1.2}}' , sort: true , align:'center' },
            {% endif %}
            {% if zd_list.0.3 %}
            {field:'{{zd_list.0.3}}', title:'{{zd_list.1.3}}', sort: true , align:'center' },
            {% endif %}


                 {fixed: 'right', title:'权限操作',width:450, toolbar: '#barDemo', align:'center' }
    ]]


        });




        //工具栏事件
        table.on('toolbar(test)', function(obj){
            var checkStatus = table.checkStatus(obj.config.id);

            switch(obj.event){



                case 'isAll':
                    window.location.reload();//刷新页面
                    break;


                };
            }


            );


        //监听表格列表
        table.on('tool(test)', function(obj){
            var data = obj.data;
            //查看
            if(obj.event === 'menu'){


                     layer.open({
                      type: 2,
                      title: true,
                         title:data.gname_str+"-访问权限",
                      area: ['{{xitong.wide_int}}px', '700px'],
                      offset: 't',

                      content: ['/{{get_url}}_menu/?posturl={{get_url}}&qxid='+data.id, ], //iframe的url，no代表不显示滚动条
                    btn: ['关闭退出'] ,
                           yes: function(){
                                 layer.closeAll();
                                },


                    });

            }
                        else if(obj.event === 'added'){


                     layer.open({
                      type: 2,
                      title: true,
                         title:data.gname_str+"-新增权限",
                      area: ['{{xitong.wide_int}}px', '700px'],
                      offset: 't',

                      content: ['/{{get_url}}_added/?posturl={{get_url}}&qxid='+data.id, ], //iframe的url，no代表不显示滚动条
                    btn: ['关闭退出'] ,
                           yes: function(){
                                 layer.closeAll();
                                },


                    });

            }
             else if(obj.event === 'delete'){


                     layer.open({
                      type: 2,
                      title: true,
                         title:data.gname_str+"-删除权限",
                      area: ['{{xitong.wide_int}}px', '700px'],
                      offset: 't',

                      content: ['/{{get_url}}_delete/?posturl={{get_url}}&qxid='+data.id, ], //iframe的url，no代表不显示滚动条
                    btn: ['关闭退出'] ,
                           yes: function(){
                                 layer.closeAll();
                                },


                    });

            }
            else if(obj.event === 'update'){


                     layer.open({
                      type: 2,
                      title: true,
                         title:data.gname_str+"-修改权限",
                      area: ['{{xitong.wide_int}}px', '700px'],
                      offset: 't',

                      content: ['/{{get_url}}_update/?posturl={{get_url}}&qxid='+data.id, ], //iframe的url，no代表不显示滚动条
                    btn: ['关闭退出'] ,
                           yes: function(){
                                 layer.closeAll();
                                },


                    });

            }

                        else if(obj.event === 'see'){


                     layer.open({
                      type: 2,
                      title: true,
                         title:data.gname_str+"-开发者权限",
                      area: ['{{xitong.wide_int}}px', '700px'],
                      offset: 't',

                      content: ['/{{get_url}}_see/?posturl={{get_url}}&qxid='+data.id, ], //iframe的url，no代表不显示滚动条
                    btn: ['关闭退出'] ,
                           yes: function(){
                                 layer.closeAll();
                                },


                    });

            }
        });




    });

</script>








<script>
layui.use(['form', 'layedit', 'laydate'], function(){
  var form = layui.form
  ,layer = layui.layer
  ,layedit = layui.layedit
  ,laydate = layui.laydate;

  //日期
  laydate.render({
    elem: '#date'
  });
  laydate.render({
    elem: '#date1'
  });

  //创建一个编辑器
  var editIndex = layedit.build('LAY_demo_editor');

  //自定义验证规则
  form.verify({
    title: function(value){
      if(value.length < 5){
        return '标题至少得5个字符啊';
      }
    }
    ,pass: [
      /^[\S]{6,12}$/
      ,'密码必须6到12位，且不能出现空格'
    ]
    ,content: function(value){
      layedit.sync(editIndex);
    }
  });

  //监听指定开关
  form.on('switch(switchTest)', function(data){
    layer.msg('开关checked：'+ (this.checked ? 'true' : 'false'), {
      offset: '6px'
    });
    layer.tips('温馨提示：请注意开关状态的文字可以随意定义，而不仅仅是ON|OFF', data.othis)
  });

  //监听提交
  form.on('submit(demo1)', function(data){
    layer.alert(JSON.stringify(data.field), {
      title: '最终的提交信息'
    })
    return false;
  });

  //表单赋值
  layui.$('#LAY-component-form-setval').on('click', function(){
    form.val('example', {
      "username": "贤心" // "name": "value"
      ,"password": "123456"
      ,"interest": 1
      ,"like[write]": true //复选框选中状态
      ,"close": true //开关状态
      ,"sex": "女"
      ,"desc": "我爱DNGadmin"
    });
  });

  //表单取值
  layui.$('#LAY-component-form-getval').on('click', function(){
    var data = form.val('example');
    alert(JSON.stringify(data));
  });

});
</script>






</body>
</html>
